import { Typography } from 'antd';
import React from 'react';

import { DAL } from '@donnu-prod-practice/dal';

import { Task2PanelPresentation } from './Task2Panel.presentation';

/* -------------------------------------------------------------------------- */
/*                                  COMPONENT                                 */
/* -------------------------------------------------------------------------- */

export const Task2Panel = React.memo<Props>(() => {
  const { countryList, isLoading, error } = DAL.country.getTask2.useGetTask2();

  return (
    <>
      {isLoading && <Typography.Text type="warning">Загрузка</Typography.Text>}

      {!!countryList && <Task2PanelPresentation countryList={countryList} />}

      {!isLoading && !countryList && (
        <Typography.Text type="danger">Ошибка: {error || 'что-то пошло не так'}</Typography.Text>
      )}
    </>
  );
});

/* -------------------------------------------------------------------------- */
/*                                 / COMPONENT                                */
/* -------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------- */
/*                                    TYPES                                   */
/* -------------------------------------------------------------------------- */

interface Props {}

/* -------------------------------------------------------------------------- */
/*                                   / TYPES                                  */
/* -------------------------------------------------------------------------- */
